-
Notifications
You must be signed in to change notification settings - Fork 0
Add option to increase specificity of class for styled components #1
base: master
Are you sure you want to change the base?
Add option to increase specificity of class for styled components #1
Conversation
src/utils/options.js
Outdated
export const useMinify = (state) => getOption(state, 'minify') | ||
export const useCSSPreprocessor = (state) => getOption(state, 'preprocess', false) // EXPERIMENTAL | ||
export const useTranspileTemplateLiterals = (state) => getOption(state, 'transpileTemplateLiterals') | ||
export const useIncreaseSpecificityClass = state => getOption(state, 'specificityClass', null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually these are called "namespace classes" (not to be confused with CSS namespaces which serve a different purpose). Perhaps that terminology would be more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Great name suggestion @harrismd! Fixed. |
const namespaceClassOption = Array.isArray(namespaceClasses) ? | ||
t.arrayExpression(namespaceClasses) | ||
: t.stringLiteral(namespaceClass); | ||
withConfigProps.push(t.objectProperty(t.identifier('namespaceClass'), namespaceClassOption)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be: t.identifier('namespaceClasses')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is accessing the value in the config...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved pending double-check of that one constant.
@harrismd - Fixed. Apologies that was a bit of a work in progress when you saw it. Had to make some other changes due to how babel-types work. |
2915b8d
to
cd97215
Compare
This PR works with QuickBase/styled-components#3
It allows the specificity class to be set through a babel plugin configuration.
or for a list of classes
Results in classes to be pre-prended with the specificity class.
E.g.,